﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;

namespace Userinterface_Ver._1_
{
    public partial class frmCapNhapUser : DevComponents.DotNetBar.Office2007Form
    {
        public frmCapNhapUser()
        {
            InitializeComponent();
        }

        private void cobRole_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        private void frmCapNhapUser_Load(object sender, EventArgs e)
        {
            string sql = "select * from USERS";
            OracleDataAdapter da = new OracleDataAdapter(sql,clsConnectDatabase.con);
            DataSet dsname = new DataSet();
            da.Fill(dsname);
            DataTable dt = dsname.Tables[0];
            cobusername.DataSource = dt;
            cobusername.DisplayMember = "USER_NAME";
           
            string sql1 = "select * from VAI_TRO";
            OracleDataAdapter da1 = new OracleDataAdapter(sql1, clsConnectDatabase.con);
            DataSet dsrole = new DataSet();
            da1.Fill(dsrole);
            DataTable dt1 = dsrole.Tables[0];
            cobrole.DataSource = dt1;
            cobrole.DisplayMember = "TEN_VAITRO";
            cobrole.ValueMember = "MA_VAITRO";
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql = "update USERS SET USER_ROLE='" + cobrole.Text + "' where USER_NAME='" + cobusername.Text + "'";
            OracleCommand com = new OracleCommand(sql,clsConnectDatabase.con);
            com.ExecuteNonQuery();
        }

        private void cobusername_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
